package com.wanmait.wanmarecruit.manageController;

import com.github.pagehelper.PageInfo;
import com.wanmait.wanmarecruit.entity.Position;
import com.wanmait.wanmarecruit.service.ConfigService;
import com.wanmait.wanmarecruit.service.PositionService;
import com.wanmait.wanmarecruit.util.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("manage")
public class ManageAuditPositionController {

    @Resource
    private PositionService positionService;
    @Resource
    private ConfigService configService;

    @RequestMapping("getAllAuditPositions")
    public AjaxResult getAllAuditPositions(Integer pageNum)
    {
        Integer pageSize = Integer.parseInt(configService.getByKeyword("position_audit_paging_size").getConfigValue());
        PageInfo<Position> positions = positionService.selectAllNotEnablePositions(pageNum,pageSize);
        return AjaxResult.success("查询成功").put("positions",positions);
    }

    @GetMapping("passThePosition")
    public AjaxResult passThePosition(Integer id)
    {
        positionService.updateEnablePosition(id);
        return AjaxResult.success("发布成功");
    }

    @GetMapping("deleteThePosition")
    public AjaxResult deleteThePosition(Integer id)
    {
        positionService.deleteOnePosition(id);
        return AjaxResult.success("删除成功");
    }
}
